class Solution:
    def sumOddLengthSubarrays(self, arr: list) -> int:
        preSum = [0]
        curSum = 0
        res = 0
        for num in arr:
            curSum += num
            preSum.append(curSum)
        for i in range(1, len(preSum)):
            if i % 2 == 0:
                j = 1
            else:
                j = 0
            while j < i:
                res += preSum[i] - preSum[j]
                j += 2
        return res
